#ifndef CONFIG_H
#define CONFIG_H

#include <QObject>


#include <QCoreApplication>
#include <QSettings>
#include <QDebug>
#include <QDateTime>
#include <QTime>
#include <QDate>

class Config : public QObject
{
    Q_OBJECT

    // PLC 连接属性
    Q_PROPERTY(QString plc_Port READ plc_Port WRITE setPlc_Port NOTIFY plc_PortChanged FINAL)
    Q_PROPERTY(QString plc_BaudRate READ plc_BaudRate WRITE setPlc_BaudRate NOTIFY plc_BaudRateChanged FINAL)
    Q_PROPERTY(QString plc_DataBit READ plc_DataBit WRITE setPlc_DataBit NOTIFY plc_DataBitChanged FINAL)
    Q_PROPERTY(QString plc_Parity READ plc_Parity WRITE setPlc_Parity NOTIFY plc_ParityChanged FINAL)
    Q_PROPERTY(QString plc_Stopbit READ plc_Stopbit WRITE setPlc_Stopbit NOTIFY plc_StopbitChanged FINAL)

    // 打印机 连接属性
    Q_PROPERTY(QString printer_Port READ printer_Port WRITE setPrinter_Port NOTIFY printer_PortChanged FINAL)
    Q_PROPERTY(QString printer_BaudRate READ printer_BaudRate WRITE setPrinter_BaudRate NOTIFY printer_BaudRateChanged FINAL)
    Q_PROPERTY(QString printer_DataBit READ printer_DataBit WRITE setPrinter_DataBit NOTIFY printer_DataBitChanged FINAL)
    Q_PROPERTY(QString printer_Parity READ printer_Parity WRITE setPrinter_Parity NOTIFY printer_ParityChanged FINAL)
    Q_PROPERTY(QString printer_Stopbit READ printer_Stopbit WRITE setPrinter_Stopbit NOTIFY printer_StopbitChanged FINAL)

    // 扫码枪 连接属性
    Q_PROPERTY(QString scanner_Port READ scanner_Port WRITE setScanner_Port NOTIFY scanner_PortChanged FINAL)
    Q_PROPERTY(QString scanner_BaudRate READ scanner_BaudRate WRITE setScanner_BaudRate NOTIFY scanner_BaudRateChanged FINAL)
    Q_PROPERTY(QString scanner_DataBit READ scanner_DataBit WRITE setScanner_DataBit NOTIFY scanner_DataBitChanged FINAL)
    Q_PROPERTY(QString scanner_Parity READ scanner_Parity WRITE setScanner_Parity NOTIFY scanner_ParityChanged FINAL)
    Q_PROPERTY(QString scanner_Stopbit READ scanner_Stopbit WRITE setScanner_Stopbit NOTIFY scanner_StopbitChanged FINAL)

    // 加密密码
    Q_PROPERTY(QString inputPasswd READ inputPasswd WRITE setInputPasswd NOTIFY inputPasswdChanged FINAL)


    // 加密 - 年
    Q_PROPERTY(QString lock_Year READ lock_Year WRITE setLock_Year NOTIFY lock_YearChanged FINAL)
    // 加密 - 月
    Q_PROPERTY(QString lock_Month READ lock_Month WRITE setLock_Month NOTIFY lock_MonthChanged FINAL)
    // 加密 - 日
    Q_PROPERTY(QString lock_Day READ lock_Day WRITE setLock_Day NOTIFY lock_DayChanged FINAL)
    // 加密 - 时
    Q_PROPERTY(QString lock_Hour READ lock_Hour WRITE setLock_Hour NOTIFY lock_HourChanged FINAL)
    // 加密 - 分
    Q_PROPERTY(QString lock_Minute READ lock_Minute WRITE setLock_Minute NOTIFY lock_MinuteChanged FINAL)
    // 加密 - 序列号
    Q_PROPERTY(QString lock_Order READ lock_Order WRITE setLock_Order NOTIFY lock_OrderChanged FINAL)
    // 加密 - 厂家码
    Q_PROPERTY(QString lock_Custom READ lock_Custom WRITE setLock_Custom NOTIFY lock_CustomChanged FINAL)


    // 打印机类型
    Q_PROPERTY(int Printer_Type READ Printer_Type WRITE setPrinter_Type NOTIFY Printer_TypeChanged FINAL)

    // 二维码类型
    Q_PROPERTY(int QR_Code_Type READ QR_Code_Type WRITE setQR_Code_Type NOTIFY QR_Code_TypeChanged FINAL)

    // 在线二维码类型
    Q_PROPERTY(int NetWork_QR_Type READ NetWork_QR_Type WRITE setNetWork_QR_Type NOTIFY NetWork_QR_TypeChanged FINAL)

    // 当前语言类型
    Q_PROPERTY(int Language_Type READ Language_Type WRITE setLanguage_Type NOTIFY Language_TypeChanged FINAL)

public:
    Config(QObject *parent = nullptr);
    ~Config();

    // 初始化全部参数
    void init_All_Data();
    // 保存全部参数
    void save_All_Data();

    Q_INVOKABLE void getPassWord(QString input_Passwd);

    QDateTime lockTime;



    QString plc_Port() const;
    void setPlc_Port(const QString &newPlc_Port);

    QString plc_BaudRate() const;
    void setPlc_BaudRate(const QString &newPlc_BaudRate);

    QString plc_DataBit() const;
    void setPlc_DataBit(const QString &newPlc_DataBit);

    QString plc_Parity() const;
    void setPlc_Parity(const QString &newPlc_Parity);

    QString plc_Stopbit() const;
    void setPlc_Stopbit(const QString &newPlc_Stopbit);

    QString printer_Port() const;
    void setPrinter_Port(const QString &newPrinter_Port);

    QString printer_BaudRate() const;
    void setPrinter_BaudRate(const QString &newPrinter_BaudRate);

    QString printer_DataBit() const;
    void setPrinter_DataBit(const QString &newPrinter_DataBit);

    QString printer_Parity() const;
    void setPrinter_Parity(const QString &newPrinter_Parity);

    QString printer_Stopbit() const;
    void setPrinter_Stopbit(const QString &newPrinter_Stopbit);

    QString scanner_Port() const;
    void setScanner_Port(const QString &newScanner_Port);

    QString scanner_BaudRate() const;
    void setScanner_BaudRate(const QString &newScanner_BaudRate);

    QString scanner_DataBit() const;
    void setScanner_DataBit(const QString &newScanner_DataBit);

    QString scanner_Parity() const;
    void setScanner_Parity(const QString &newScanner_Parity);

    QString scanner_Stopbit() const;
    void setScanner_Stopbit(const QString &newScanner_Stopbit);

    QString inputPasswd() const;
    void setInputPasswd(const QString &newInputPasswd);

    QString lock_Year() const;
    void setLock_Year(const QString &newLock_Year);

    QString lock_Month() const;
    void setLock_Month(const QString &newLock_Month);

    QString lock_Day() const;
    void setLock_Day(const QString &newLock_Day);

    QString lock_Hour() const;
    void setLock_Hour(const QString &newLock_Hour);

    QString lock_Minute() const;
    void setLock_Minute(const QString &newLock_Minute);

    QString lock_Order() const;
    void setLock_Order(const QString &newLock_Order);

    QString lock_Custom() const;
    void setLock_Custom(const QString &newLock_Custom);

    int Printer_Type() const;
    void setPrinter_Type(int newPrinter_Type);

    int QR_Code_Type() const;
    void setQR_Code_Type(int newQR_Code_Type);

    int Language_Type() const;
    void setLanguage_Type(int newLanguage_Type);

    int NetWork_QR_Type() const;
    void setNetWork_QR_Type(int newNetWork_QR_Type);

signals:
    void plc_PortChanged();

    void plc_BaudRateChanged();

    void plc_DataBitChanged();

    void plc_ParityChanged();

    void plc_StopbitChanged();

    void printer_PortChanged();

    void printer_BaudRateChanged();

    void printer_DataBitChanged();

    void printer_ParityChanged();

    void printer_StopbitChanged();

    void scanner_PortChanged();

    void scanner_BaudRateChanged();

    void scanner_DataBitChanged();

    void scanner_ParityChanged();

    void scanner_StopbitChanged();

    void inputPasswdChanged();

    void lock_YearChanged();

    void lock_MonthChanged();

    void lock_DayChanged();

    void lock_HourChanged();

    void lock_MinuteChanged();

    void lock_OrderChanged();

    void lock_CustomChanged();


    void Printer_TypeChanged();

    void QR_Code_TypeChanged();


    void Language_TypeChanged();

    void NetWork_QR_TypeChanged();

public slots:

    void Get_Passwd_Need_To_Save(QString passwd);

private:
    QString m_plc_Port;
    QString m_plc_BaudRate;
    QString m_plc_DataBit;
    QString m_plc_Parity;
    QString m_plc_Stopbit;

    QString m_printer_Port;
    QString m_printer_BaudRate;
    QString m_printer_DataBit;
    QString m_printer_Parity;
    QString m_printer_Stopbit;

    QString m_scanner_Port;
    QString m_scanner_BaudRate;
    QString m_scanner_DataBit;
    QString m_scanner_Parity;
    QString m_scanner_Stopbit;
    QString m_inputPasswd;

    QString m_lock_Year;
    QString m_lock_Month;
    QString m_lock_Day;
    QString m_lock_Hour;
    QString m_lock_Minute;
    QString m_lock_Order;
    QString m_lock_Custom;
    int m_Printer_Type;
    int m_QR_Code_Type;
    int m_Language_Type;
    int m_NetWork_QR_Type;
};

#endif // CONFIG_H
